<?php
/**
 * The default template for displaying content. Used for both single and index/archive/search.
 *
 * @package WordPress
 * @subpackage Sastro
 * @since Sastro 1.0
 */
 
 global $post, $more;
 $more = 0;
 $initial = THE_INITIAL;
?>

    <?php /* How to display all posts. */ ?>
	<article id="post-<?php the_ID(); ?>" <?php post_class("content-loop"); ?>>
    	<div class="stickybadge"></div>
		<?php
		if(!is_search()){
			$custom = get_post_custom($post->ID);
			$cf_imgurl = (isset($custom["image_url"][0]))? $custom["image_url"][0] : "";
			$imgurl = "";
			/* temporary not used */
			if($cf_imgurl!=""){
				$imgurl = '<img src='. $cf_imgurl .' alt="'. get_the_title( $post->ID ).'" class="scale-with-grid"/>';
			}elseif(has_post_thumbnail($post->ID) ){
				$imgurl = get_the_post_thumbnail($post->ID, 'blog-post-image', array('class' => 'scale-with-grid'));
			}else{
				$imgurl ="";
			}
			
			if($imgurl!=''){
				echo '<div class="imgcontainer">'.$imgurl."</div>";
			}
		}
		?>
        <div class="loopcontainer">
            <h2 class="posttitle"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', THE_LANG ), the_title_attribute( 'echo=0' ) ); ?>" data-rel="bookmark"><?php the_title(); ?></a></h2>
            <div class="entry-utility">
                <span class="meta-author"><?php _e('By', THE_LANG); ?> <a href="<?php echo get_author_posts_url( get_the_author_meta( 'ID' ) );?>"><?php the_author();?></a></span>&nbsp;&nbsp;/&nbsp;&nbsp;
                <span class="meta-date"><i class="fa fa-calendar"></i>&nbsp; <?php the_time('M d, Y') ?></span>&nbsp;&nbsp;/&nbsp;&nbsp;
                <span class="meta-cat"><i class="fa fa-folder-open"></i>&nbsp; <?php the_category(', '); ?></span>&nbsp;&nbsp;/&nbsp;&nbsp;
                <span class="meta-comment"><i class="fa fa-comments"></i>&nbsp; <?php comments_popup_link(__('0 Comment', THE_LANG), __('1 Comment', THE_LANG), __('% Comments', THE_LANG)); ?></span>
                <div class="clearfix"></div>
            </div>
            <div class="entry-icon"><div class="fa fa-camera"></div></div>
       		<div class="entry-content">
                <?php the_excerpt(); ?>
                <div class="clearfix"></div>
            </div>
            <a href="<?php the_permalink(); ?>" class="more-link btn"><?php _e('Continue Reading', THE_LANG); ?></a>
            <?php 
			$adminurl = THE_ADMINURL;
			$nonce = wp_create_nonce("nvr_quickread_nonce");
			$ajaxlink = $adminurl.'admin-ajax.php?ajax=true&action=nvr_quickread&post_id='.get_the_ID().'&nonce='.$nonce;
			echo '<a class="quickread more-link btn" href="'.$ajaxlink.'" title="'.get_the_title( get_the_ID() ).'" data-pid="'.get_the_ID().'">'.__('Quick Read', THE_LANG).'</a>';
			?>
            <div class="clearfix"></div>
        	<?php do_action('nvr_share_button'); ?>
            <div class="clearfix"></div>
        </div>
		<div class="clearfix"></div>
        
	</article><!-- end post -->